Monitore Storage in AWS EC2
Step 1
Step 2
Install CloudWatch agent
- In EC2 instance Terminal
cd /tmp
wget https://s3.amazonaws.com/amazoncloudwatch-agent/ubuntu/amd64/latest/amazon-cloudwatch-agent.deb
sudo dpkg -i -E ./amazon-cloudwatch-agent.deb
- Configure CloudWatch agent
sudo vi /opt/aws/amazon-cloudwatch-agent/etc/amazon-cloudwatch-agent.json
- enter the following snippet in the above file
{
"agent": {
"metrics_collection_interval": 60,
"run_as_user": "cwagent"
},
"metrics": {
"append_dimensions": {
"InstanceId": "${aws:InstanceId}"
},
"metrics_collected": {
"disk": {
"measurement": [
"used_percent"
],
"metrics_collection_interval": 60,
"resources": [
"/"
]
}
}
}
}
sudo systemctl restart amazon-cloudwatch-agent (restarts the cloudwatch agent)
tail -f /opt/aws/amazon-cloudwatch-agent/logs/amazon-cloudwatch-agent.log